package mae.app;

import vitrock.mae.app.Vitrock;
import holiday.mae.app.Holiday;
import madrid.mae.app.Madrid;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import as.mae.app.AmericanSweetheart;

/**
 * The DepressionGlass class which shows a list of patterns the user may select.
 * 
 * @author Dennis Stepp
 * @version 1.0z Build 1 June 7, 2011
 * 
 */
public class DepressionGlass extends ListActivity {

	/*
	 * A TextView called selection
	 */
	TextView selection;
	/*
	 * A list of Depression Glass patterns and corresponding the Activity class.
	 */
	static final ListItemActivities[] patterns = {
			new ListItemActivities("American Sweetheart",
					AmericanSweetheart.class),
			new ListItemActivities("Holiday", Holiday.class),
			new ListItemActivities("Madrid", Madrid.class),
			new ListItemActivities("Vitrock", Vitrock.class) };

	/**
	 * Creates the Depression Glass Activity for the application. Sets the
	 * layout which displays a list of depression glass patterns.
	 */
	@Override
	public void onCreate(Bundle savedInstancestate) {
		super.onCreate(savedInstancestate);
		setListAdapter(new ArrayAdapter<ListItemActivities>(this,
				android.R.layout.simple_list_item_1, patterns));
		selection = (TextView) findViewById(R.id.selection);
	}

	/**
	 * Provide a click listener for the list view and will start the activity
	 * that matches the click item.
	 */
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		final Intent intent = new Intent(this, patterns[position].getActivity());
		startActivityForResult(intent, position);
	}
}
